package com.lupan.tomcatStudy.javaStudy.chapter16.threadNotify;

import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
 * 说明：
 *
 * @author lupan
 * @version 2017/3/15 15:09
 */
public class LockPojo {

    private String vin;
    //用于阻塞线程的锁
    private final Lock lock = new ReentrantLock();
    private final Condition condition = lock.newCondition();

    public void run(String threadName) {
        lock.lock();
        try {
            for (int i = 0; i < 10000; i++) {
                System.out.println(threadName + ":" + i);
                condition.await();
            }
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            lock.unlock();
        }
    }


    public String getVin() {
        return vin;
    }

    public void setVin(String vin) {
        this.vin = vin;
    }

    public Condition getCondition() {
        return condition;
    }
}
